import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Util {

	//得到产品类别
	public static String getProductCategories(String zqUrl){
		
	     String zq[]	= zqUrl.split("[?]");
         String canshuMap = zq[1];
         String canshu[] =canshuMap.split("&");
         String vcid= "";
         for (String str : canshu) {
      	   String map[] = str.split("=");
      	   if (map[0].equals("vcid")) {
      		   vcid= map[1];
      	   }
         }
         return vcid;
	}
	
	
	
	//取以_COLOR开头以;结尾
	public static String getColorArray(String html){ 
		String regex = " _COLOR = '([\\s\\S]*?)';"; 
		Matcher matcher = Pattern.compile(regex).matcher(html); 
		if (matcher.find()){ 
		return matcher.group(1).trim(); 
		} 
		return ""; 
	} 
	
	
	public static String getdetailsHtml(String html){ 
		String regex = "descTemplate\">([\\s\\S]*?)</script>"; 
		Matcher matcher = Pattern.compile(regex).matcher(html); 
		if (matcher.find()){ 
		return matcher.group(1).trim(); 
		} 
		return ""; 
	} 
	
	
	 public static String  StringFilter(String str) { 
		String regEx1="[实][拍]"; 
		String regEx2="[实][价]"; 
		String regEx3="[\\s！~～;。：，]"; 
		String regEx4="2017"; 
		String regEx5="[以][检][测]"; 
		String regEx6="[质][检]"; 
		String regEx7="[现][货]";
	
		Pattern p1 = Pattern.compile(regEx1); 
		Matcher m1 = p1.matcher(str);
		Pattern p2 = Pattern.compile(regEx2); 
		Matcher m2 = p2.matcher(m1.replaceAll("").trim());
		Pattern p3 = Pattern.compile(regEx3); 
		Matcher m3 = p3.matcher(m2.replaceAll("").trim());
		Pattern p4 = Pattern.compile(regEx4); 
		Matcher m4 = p4.matcher(m3.replaceAll("").trim());
		Pattern p5 = Pattern.compile(regEx5); 
		Matcher m5 = p5.matcher(m4.replaceAll("2018").trim());
		
		Pattern p6 = Pattern.compile(regEx6); 
		Matcher m6 = p6.matcher(m5.replaceAll("").trim());
		
		Pattern p7 = Pattern.compile(regEx7); 
		Matcher m7 = p7.matcher(m6.replaceAll("").trim());
		
		System.out.println(m7.replaceAll("").trim());
		return m7.replaceAll("").trim();

	} 
	
 
}
